<?php

/* 
 * Copyright (C) 2014 vlasta81
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Description of Router
 *
 * @author vlasta81
 */

namespace system;

final class router {

    private $getUrl = array();

    public function __construct() {
        $urlArray = explode('/', trim(strtolower(preg_replace('/<[^<]+?(.*)>/i', '', filter_input(INPUT_GET, 'url', FILTER_SANITIZE_URL))), DS));
        if (empty($urlArray[0])) : $urlArray[0] = 'home';
        endif;
        if (empty($urlArray[1])) : $urlArray[1] = 'home';
        endif;
        if (empty($urlArray[2])) : $urlArray[2] = 'home';
        endif;
        $urlArray[0] = strtolower($urlArray[0]);
        $urlArray[1] = strtolower($urlArray[1]);
        $urlArray[2] = strtolower($urlArray[2]);
        $this->getUrl = $urlArray;
    }

    public function getRoute() {
        $newArray = array();
        $newArray = $this->getUrl;
        return array_filter($newArray);
    }

}

